package exerr

import "net/http"

// 错误码规则:
// *** 如果是分布式系统，建议单独项目进行定义 ***
// ----------------------------------------------------------
//
//	HTTP状态码     自定义错误码     错误内容	    错误提示
//
// ----------------------------------------------------------
var (
	// ------------------------------- [  成功 ] ------------------------------- //

	OK = Register(http.StatusOK, 10000, "操作成功", "ok")

	// ------------------------------- [ 服务内部错误 ] ------------------------------- //

	Err        = Register(500, 10001, "服务错误", "Internal server failed")
	Unknown    = Register(500, 10002, "未知错误", "Unknown error")
	DB         = Register(500, 10003, "数据库相关错误", "Internal db failed")
	Redis      = Register(500, 10004, "REDIS错误", "Internal redis failed")
	RPC        = Register(500, 10005, "RPC相关错误", "Internal grpc failed")
	ThirdParty = Register(500, 10006, "第三方接口调用失败", "Third-party API call failed")
	SystemBusy = Register(500, 10007, "系统繁忙，请稍后再试", "System busy, please try again later")

	// ------------------------------- [ 接口通用错误 ] ------------------------------- //

	RequestFail      = Register(400, 20001, "非法请求路径", "Invalid Request Path")
	FrequencyTooMany = Register(400, 20002, "请求过于频繁", "Too many requests")
	RequestTimeout   = Register(400, 20003, "请求超时", "Request timeout")
	ParamInvalid     = Register(200, 20004, "请求参数错误", "invalid param")

	// ------------------------------- [ 鉴权业务错误 ] ------------------------------- //

	TokenExpired      = Register(401, 30001, "登录失效，请重新登录", "Token expired")
	TokenNotValidYet  = Register(401, 30002, "Token尚未生效", "Token not valid yet")
	TokenEmpty        = Register(401, 30003, "未登录，请先登录", "empty Token")
	TokenInvalid      = Register(401, 30004, "AccessToken无效", "Invalid access token")
	TokenNoPermission = Register(400, 30005, "权限不足", "Permission denied")

	// ------------------------------- [ 数据业务错误 ] ------------------------------- //

	DataNotFound = Register(400, 40001, "数据不存在", "Data not found")
	DataExisted  = Register(400, 40002, "数据已存在", "Data already exists")

	// ------------------------------- [ 用户相关 ] ------------------------------- //

	UserNotFound    = Register(400, 12001, "用户不存在", "User does not exist")
	UserPasswordErr = Register(400, 12002, "密码错误", "Wrong password")
)
